package edu.sctu.zhengsenwen.month201506.day20150617;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowEvent;

/**
 * 标题：HelloWorld类文件
 * Created by user15 on 2015/6/17.
 */
public class HelloFrame extends JFrame {

    JPanel contentPane;

    BorderLayout borderLayout = new BorderLayout();

    JLabel jLabel = new JLabel();


    public static void main(String[] args) {

        //创建窗口类
        HelloFrame frame = new HelloFrame();
        Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension framesize = frame.getSize();

        //使窗口类居中对齐

        frame.setLocation((screensize.width - screensize.width)/2,framesize.height - framesize.height);

        //显示窗口类

        frame.setVisible(true);
    }


    //程序的构造器
    public HelloFrame(){

        try{
            JbInit();
        }catch (Exception ex){}
    }

    /**
     * 生成可视化界面的方法
     */
    private void JbInit() {

        contentPane = (JPanel) this.getContentPane();

        contentPane.setLayout(borderLayout);

        this.setTitle("欢迎窗口");

        //设置标签字体
        jLabel.setFont(new java.awt.Font("Dialog",1,16));


        //设置标签的文字
        jLabel.setText("  Welcome Java 亲爱的读者，欢迎来到Java世界！");

        contentPane.add(jLabel,BorderLayout.CENTER);
    }


    //关闭窗口的方法
    public void processWindowEvent(WindowEvent event){

        if(event.getID() == WindowEvent.WINDOW_CLOSING){

            System.out.println(0);

        }
    }
}
